<?php

declare(strict_types=1);

namespace app\admin\controller;

use addons\Builder\facade\Builder;
//该文件为自动生成，请按需修改
class Signup extends Base
{
    //主键，默认为id
    protected string $pk = 'id';

    //主模型
    protected string $model = '\app\common\model\Signup';

    protected $append = ['sexText', 'cateText'];

    protected int $takeOver = 3;

    public function index(): string
    {
        $param = $this->request->param();
        if (isset($param['exportUser']) && $param['exportUser'] == 1) {
            return Builder::Table()
                ->autoStructure($this->model, $this->pk)
                ->addRightButtons(['delete'])
                ->addSearch([
                    ['rname', '报名姓名', 'input,Like'],
                    ['tel', '报名电话', 'input,Like'],
                ])
                ->fetch('signup/index');
        } else {
            return Builder::Table()
                ->autoStructure($this->model, $this->pk, 'barDemo,200')
                ->addRightButtons(['delete'])
                ->addTopButtons([
                    'deleteAll',
                    'dropdown' => [
                        'title' => '导出数据',
                        'icon' => 'layui-icon-upload-drag',
                        'class' => 'normal import-boost Dropdown',
                        'layon' => '.Dropdown',
                        'event' => '_dropdownExcel',
                        'init' => true
                    ]
                ])
                ->addSearch([
                    ['rname', '报名姓名', 'input,Like'],
                    ['tel', '报名电话', 'input,Like'],
                ])
                ->fetch();
        }
    }
}
